<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Fil数据导出</title>
    <script src="/statics/jquery-3.6.0.js"></script>
</head>
<body>
<h3>Message数据下载：</h3>
<form id="fmessage" action="/message" method="post">
    <tr>
        <td>Type:</td>
        <td>
            <select name="type">
                <option value="">all</option>
                <option value="ChangeMultiaddrs">ChangeMultiaddrs</option>
                <option value="ChangeOwnerAddress">ChangeOwnerAddress</option>
                <option value="ChangeWorkerAddress">ChangeWorkerAddress</option>
                <option value="CreateMiner">CreateMiner</option>
                <option value="DeclareFaultsRecovered">DeclareFaultsRecovered</option>
                <option value="PreCommitSector">PreCommitSector</option>
                <option value="PreCommitSectorBatch">PreCommitSectorBatch</option>
                <option value="ProveCommitAggregate">ProveCommitAggregate</option>
                <option value="ProveCommitSector">ProveCommitSector</option>
                <option value="Send">Send</option>
                <option value="SubmitWindowedPoSt">SubmitWindowedPoSt</option>
                <option value="TerminateSectors">TerminateSectors</option>
                <option value="WithdrawBalance+(miner)">WithdrawBalance+(miner)</option>
            </select>
        </td>
        <td>Duration:</td>
        <td><input name="dur" value="5"/></td>
    </tr>
    <table>
        <tr>
            <td colspan="2"><h1 style="color: red;">所选时间区间必须在真实数据的有效范围内</h1></td>
        </tr>
        <tr>
            <td>起始时间：<input type="date" name="from"/></td>
            <td>截止时间：<input type="date" name="to"/></td>
        </tr>
        <tr>
            <td colspan="2"><textarea name="address" rows="10" cols="100" placeholder="在这里输入帐号，一行一个帐号"></textarea></td>
        </tr>
        <tr>
            <td colspan="2"><input id="ssubmit" type="button" value="生成数据"/> <span>点击生成数据后请耐心等待，操作成功后下面会有下载链接</span>
            </td>
        </tr>
    </table>
</form>
<ol id="messages"></ol>
<br>
<br>
<br>
<h3>Transaction数据下载：</h3>
<form id="ftrans" action="/trans" method="post">
    <tr>
        <td>Type:</td>
        <td><select name="type">
            <option value="">all</option>
            <option value="burn">burn</option>
            <option value="reward">reward</option>
            <option value="transfer">transfer</option>
        </select></td>
        <td>Duration:</td>
        <td><input name="dur" value="5"/></td>
    </tr>
    <table>
        <tr>
            <td colspan="2"><h1 style="color: red;">所选时间区间必须在真实数据的有效范围内</h1></td>
        </tr>
        <tr>
            <td>起始时间：<input type="date" name="from"/></td>
            <td>截止时间：<input type="date" name="to"/></td>
        </tr>
        <tr>
            <td colspan="2"><textarea name="address" rows="10" cols="100" placeholder="在这里输入帐号，一行一个帐号"></textarea></td>
        </tr>
        <tr>
            <td colspan="2"><input id="tsubmit" type="button" value="生成数据"/> <span>点击生成数据后请耐心等待，操作成功后下面会有下载链接</span>
            </td>
        </tr>
    </table>
</form>
<ol id="trans"></ol>
</body>
</html>
<script type="text/javascript">
    $(function () {
        var asub = $("#asubmit")
        var allOl = $("ol#alls")
        var ssub = $("#ssubmit")
        var sendOl = $("ol#messages")
        var tsub = $("#tsubmit")
        var transOl = $("ol#trans")

        ssub.click(function () {
            ssub.attr({"disabled": "disabled"});
            ssub.val("请耐心等待")
            sendOl.text("")
            $.post($("#fmessage").attr("action"), $("#fmessage").serialize(), function (result) {
                ssub.removeAttr("disabled");
                ssub.val("生成数据")

                result.addresses.forEach(function (item) {
                    sendOl.append("<li><a href='" + item + "'>" + item + "</a></li>")
                })
            })
            return false
        })

        tsub.click(function () {
            tsub.attr({"disabled": "disabled"});
            tsub.val("请耐心等待")
            transOl.text("")
            $.post($("#ftrans").attr("action"), $("#ftrans").serialize(), function (result) {
                tsub.removeAttr("disabled");
                tsub.val("生成数据")

                result.addresses.forEach(function (item) {
                    transOl.append("<li><a href='" + item + "'>" + item + "</a></li>")
                })
            })
            return false
        })
    })
</script>